//package com.up.jiasai.spring.config;
//
//import com.up.vms.application.base.manager.ImageManager;
//import com.up.jiasai.interceptors.UserLoginInterceptor;
//import com.up.jiasai.spring.converter.DateConverter;
//import com.up.jiasai.spring.converter.DoubleConverter;
//import com.up.jiasai.spring.converter.IntConverter;
//import com.up.jiasai.spring.resolver.LoginArgumentResolver;
//import com.up.jiasai.spring.resolver.RequestArgumentResolver;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.convert.support.GenericConversionService;
//import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
//import org.springframework.web.method.support.HandlerMethodArgumentResolver;
//import org.springframework.web.servlet.config.annotation.CorsRegistry;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
//import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
//
//import java.util.List;
//
//import javax.annotation.PostConstruct;
//
///**
// * 文件对象
// * 功能说明：向spring boot 注册自定义的参数拦截器<br>
// * 模块名称：<br>
// * 功能描述：<br>
// * 文件名称: <br>
// * 系统名称：<br>
// * 软件著作权：icelove 版权所有<br>
// * 开发人员：icelove <br>
// * 开发时间：2019/2/14 12:54<br>
// * 系统版本：1.0.0<br>
// */
//@Configuration
//public class WebMvcConfig extends WebMvcConfigurationSupport {
//    //结果静态资源无法访问问题(上传图片直接上传到其他项目工程)
//    @Override
//    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
//        String uploadPath = ImageManager.IMGSERVER_PHYSICAL;
//        if (!uploadPath.endsWith("/")) {
//            uploadPath += "/";
//        }
//        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
//        //registry.addResourceHandler("/upload/**").addResourceLocations("file:" + uploadPath);
//        //registry.addResourceHandler("/upload/**").addResourceLocations("classpath:/upload/");
//        //这里如果是其他路径,这里的locations要填写真实的地址,如果是windows需要加上file:/
//        //registry.addResourceHandler("/upload/**").addResourceLocations("file:/E:/idealProjects/nbgh_edu_server/upload/");
//        super.addResourceHandlers(registry);
//    }
//
//    @Override
//    protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
//        //客户端拦截ClientInfo对象，提供自动绑定功能
//        argumentResolvers.add(new RequestArgumentResolver());
//        //登录拦截系统
//        argumentResolvers.add(new LoginArgumentResolver());
//        super.addArgumentResolvers(argumentResolvers);
//    }
//
//    //添加拦截器
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        // 可添加多个
////        registry.addInterceptor(new AdminLoginInterceptor()).addPathPatterns("/mes/**");
//        //APP拦截器
//        registry.addInterceptor(new UserLoginInterceptor()).addPathPatterns("/app/**","/res/**","/pay/**");
//        super.addInterceptors(registry);
//    }
//
//    //解决跨域问题
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**")
//                .allowedOrigins("*")
//                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
//                .maxAge(3600)
//                .allowCredentials(true);
//    }
//    //注册参数配置类
//    @Autowired
//    private RequestMappingHandlerAdapter handlerAdapter;
//    @PostConstruct
//    public void initEditableAvlidation() {
//        ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer)handlerAdapter.getWebBindingInitializer();
//        if(initializer.getConversionService()!=null) {
//            GenericConversionService genericConversionService = (GenericConversionService)initializer.getConversionService();
//            genericConversionService.addConverter(new DateConverter());
//            genericConversionService.addConverter(new DoubleConverter());
//            genericConversionService.addConverter(new IntConverter());
//        }
//    }
//}
